package com.estate.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.estate.mapper.PostMapper;
import com.estate.pojo.Post;
import com.estate.service.PostService;

@Controller
public class aaa {
	@Autowired
	private PostMapper postMapper;
	
	@Autowired
	private PostService postService;
	
/*	@ResponseBody
	@RequestMapping("/student_info")
	public Map<String, Object> Student_Info() {
		Map<String, Object> result=new HashMap<String,Object>();
		List<Post> postList = new ArrayList<Post>();
		
		try {
			postList =	postService.queryPost();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		for (Post post : postList) {
			System.out.println(post.getStu_in_post());
		}
		result.put("postList", postList);
		return result;
	}*/
	
	
	@RequestMapping("/info")
	public ModelAndView info(ModelAndView model) {
		model.setViewName("thymeleaf/forms");
		return model;
	}
	
	@RequestMapping("/jsp/student_info")
	public ModelAndView Student_Info(ModelAndView model) {	
		List<Post> postList = postService.queryPost();
		model.addObject("postList", postList);
		model.setViewName("jsp/test");
		return model;
	}
	
	@RequestMapping("/thymeleaf/try")
	public ModelAndView thymeleaf(ModelAndView model) {
		List<Post> postList = postService.queryPost();
		model.addObject("postList", postList);
		model.setViewName("thymeleaf/thymeleaf");
		return model;
	}
}
